package com.dianqu.weather.core.common;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;

import net.sf.json.JsonConfig;

public class Tools {

	public static String dataformat(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date);
	}

	public static boolean isChinese(String lang) {
		return lang.matches("[\u4e00-\u9fa5]+");
	}

	public static String iso2utf8(String context) {
		try {
			return new String(context.getBytes("iso8859-1"), "utf-8");
		} catch (UnsupportedEncodingException e) {
		}
		return context;
	}

	public static JsonConfig jsonConfig() {
		JsonConfig jsonConfig = new JsonConfig();
		jsonConfig.registerJsonValueProcessor(Date.class,
				new JsonDateValueProcessor());
		return jsonConfig;
	}

}
